function showport($p) {
    $conns = Get-NetTCPConnection -LocalPort $p -ErrorAction SilentlyContinue
    if ($conns) { 
        foreach ($c in $conns) { 
            $proc = Get-Process -Id $c.OwningProcess -ErrorAction SilentlyContinue
            $name = if ($proc) { $proc.ProcessName } else { "Unknown" }
            Write-Host "Port $p used by $name (PID: $($c.OwningProcess))" -ForegroundColor Red 
        } 
    } else { 
        Write-Host "Port $p is free" -ForegroundColor Green 
    }
}